home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src / proxy / store.h < prev   
C/C++ Source or Header  |  2006-10-15  |  4KB  |  116 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20. Please visit our Website: http://www.httrack.com
  21. */
  22.  
  23. /* ------------------------------------------------------------ */
  24. /* File: Cache manager for ProxyTrack                           */
  25. /* Author: Xavier Roche                                         */
  26. /* ------------------------------------------------------------ */
  27.  
  28. #ifndef WEBHTTRACK_PROXYTRACK_STORE
  29. #define WEBHTTRACK_PROXYTRACK_STORE
  30.  
  31. /* Includes */
  32. #ifndef _WIN32
  33. #include <pthread.h>
  34. #else
  35. #include "windows.h"
  36. #endif
  37.  
  38. /* Proxy */
  39.  
  40. typedef struct _PT_Index _PT_Index;
  41. typedef struct _PT_Indexes _PT_Indexes;
  42.  
  43. typedef struct _PT_Index *PT_Index;
  44. typedef struct _PT_Indexes *PT_Indexes;
  45.  
  46. typedef struct _PT_Cache _PT_Cache;
  47. typedef struct _PT_Cache *PT_Cache;
  48.  
  49. typedef struct _PT_CacheItem _PT_CacheItem;
  50. typedef struct _PT_CacheItem *PT_CacheItem;
  51.  
  52. typedef struct _PT_Element {
  53.     int indexId;           // index identifier, if suitable (!= -1)
  54.     //
  55.   int statuscode;        // status-code, -1=erreur, 200=OK,201=..etc (cf RFC1945)
  56.   char* adr;             // adresse du bloc de mΘmoire, NULL=vide
  57.   char* headers;         // adresse des en tΩtes si prΘsents (RFC822 format)
  58.   size_t size;             // taille fichier
  59.   char msg[1024];        // error message ("\0"=undefined)
  60.   char contenttype[64];  // content-type ("text/html" par exemple)
  61.   char charset[64];      // charset ("iso-8859-1" par exemple)
  62.   char* location;        // on copie dedans Θventuellement la vΘritable 'location'
  63.   char lastmodified[64]; // Last-Modified
  64.   char etag[64];         // Etag
  65.   char cdispo[256];      // Content-Disposition coupΘ
  66. } _PT_Element;
  67. typedef struct _PT_Element *PT_Element;
  68.  
  69. typedef enum PT_Fetch_Flags {
  70.     FETCH_HEADERS,                // fetch headers
  71.     FETCH_BODY                        // fetch body
  72. } PT_Fetch_Flags;
  73.  
  74. /* Locking */
  75. #ifdef _WIN32
  76. typedef void* PT_Mutex;
  77. #else
  78. typedef pthread_mutex_t PT_Mutex;
  79. #endif
  80.  
  81. void MutexInit(PT_Mutex *pMutex);
  82. void MutexLock(PT_Mutex *pMutex);
  83. void MutexUnlock(PT_Mutex *pMutex);
  84. void MutexFree(PT_Mutex *pMutex);
  85.  
  86. /* Indexes */
  87. PT_Indexes PT_New(void);
  88. void PT_Delete(PT_Indexes index);
  89. PT_Element PT_ReadIndex(PT_Indexes indexes, const char* url, int flags);
  90. int PT_LookupIndex(PT_Indexes indexes, const char* url);
  91. int PT_AddIndex(PT_Indexes index, const char *path);
  92. int PT_RemoveIndex(PT_Indexes index, int indexId);
  93. int PT_IndexMerge(PT_Indexes indexes, PT_Index *pindex);
  94. PT_Index PT_GetIndex(PT_Indexes indexes, int indexId);
  95. time_t PT_GetTimeIndex(PT_Indexes indexes);
  96.  
  97. /* Indexes list */
  98. PT_Element PT_Index_HTML_BuildRootInfo(PT_Indexes indexes);
  99. char ** PT_Enumerate(PT_Indexes indexes, const char *url, int subtree);
  100. void PT_Enumerate_Delete(char ***plist);
  101. int PT_EnumCache(PT_Indexes indexes, int (*callback)(void *, const char *url, PT_Element), void *arg);
  102. int PT_SaveCache(PT_Indexes indexes, const char *filename);
  103.  
  104. /* Index */
  105. PT_Index PT_LoadCache(const char *filename);
  106. void PT_Index_Delete(PT_Index *pindex);
  107. PT_Element PT_ReadCache(PT_Index index, const char* url, int flags);
  108. int PT_LookupCache(PT_Index index, const char* url);
  109. time_t PT_Index_Timestamp(PT_Index index);
  110.  
  111. /* Elements*/
  112. PT_Element PT_ElementNew(void);
  113. void PT_Element_Delete(PT_Element *pentry);
  114.  
  115. #endif
  116.